<template>
	<view class="walletDetais-buy">
			<view class="walletDetais-buy-list">
			        <view class="wbl wbl-item van-hairline--top-bottom"
			        	v-for="(key, index) in buys" :key="index"
						@click="goDetails(key)">
			        	<view class="wbl-item-info">
			        		<view class="wbl-item-info-id">
			        			<view class="wbl-item-info-icon iconfont iconzhuanzhang color3">
			        			</view>
			        		</view>
			        		<view class="wbl-item-info-sum">
			        			<text>{{index%3 === 0 ? '兑换为LABred': '兑换为LABtk'}}</text>
								<text class="time">{{key.time}}</text>
			        		</view>
			        	</view>
			        	<view class="wbl-item-info-sum">
			        		<text class="type" :class="{'type2': key.type > 2}"> {{key.type > 2 ? '-' : '+'}}{{key.sum}}</text>
							 <text class="uts">SEED</text>
			        	</view>
			        </view>
					<loadding-more :noData="false" :loadEnd="loadEnd"></loadding-more>
			</view>
	</view>
</template>
<script>
	import { mapActions } from 'vuex'
	import LoaddingMore from '../../../../components/loadding-more.vue';
	export default {
		props: {
			active: {
				type: Number
			}
		},
		components: {
			LoaddingMore
		},
		data() {
			return {
				buys: [],
				loadEnd: false
			};
		},
		onShow() {
			this.gitList();
		},
		onReachBottom() {
			this.gitList();
		},
		watch: {
			active(val) {
				if (this.buys.length > 1) return;
				this.gitList();
			}
		},
		methods: {
			...mapActions([
				'setTRDetails'
			]),
			goDetails (key) {
				this.setTRDetails(key)
				uni.navigateTo({
					url: '/pages/bookkeeping/record/details?type=1' 
				});
			},
			gitList () {
				if (this.active !== 2) return false;
				for(let i = 0; i < 10; i++) {
					let sum = Math.random()*(20-10)+10
					const ob = {
						time: '2019-02-10 15:20',
						sendToken: 'eeeesdcsdcsdcsdc2321323232',
						receiveToken: 'wewcdscsdcsdcsdcsdc2321323232',
						type: sum,
						sum: '200',
						remark: ''
					}
					this.buys.push(ob)
				}
			}
		},
		components: {
		}
	}
</script>
<style scoped lang="scss">
@import '../../../../common/wallet-details.scss';
</style>
